<template>
	<view class="container">
		<!-- 步骤条 -->
		<view class="steps-wrapper">
			<view class="steps-content">
				<view class="steps-item active">
					<view class="num">1</view>
					<view class="txt">法人信息</view>
				</view>
				<view class="steps-item" :class="{ active: [2, 3, 4, 5].includes(stepIndex) }">
					<view class="num">2</view>
					<view class="txt">经营信息</view>
					<view class="link" />
				</view>
				<view class="steps-item" :class="{ active: [3, 4, 5].includes(stepIndex) }">
					<view class="num">3</view>
					<view class="txt">结算信息</view>
					<view class="link" />
				</view>
				<view class="steps-item" :class="{ active: [4, 5].includes(stepIndex) }">
					<view class="num">4</view>
					<view class="txt">店铺认证</view>
					<view class="link" />
				</view>
				<view class="steps-item" :class="{ active: [5, 6].includes(stepIndex) }">
					<view class="num">5</view>
					<view class="txt">费率确认</view>
					<view class="link" />
				</view>
			</view>
		</view>
		<realName :submitShow="false" v-if="stepIndex == 1" @upBtn="upBtn" @nextBtn="nextBtn"></realName>
		<operate v-if="stepIndex == 2" ref="childOperateRef" @upBtn="upBtn" @nextBtn="nextBtn"></operate>
		<bank v-if="stepIndex == 3" @upBtn="upBtn" @nextBtn="nextBtn"></bank>
		<supplement v-if="stepIndex == 4" @upBtn="upBtn" @nextBtn="nextBtn"></supplement>
		<rate v-if="stepIndex == 5" @upBtn="upBtn" @nextBtn="nextBtn" :scanResult="scanResult"></rate>

	</view>
</template>

<script setup>
	import {
		onLoad,
		onShow
	} from "@dcloudio/uni-app";
	import {
		ref,
		reactive
	} from "vue";
	import {
		showToast
	} from "@/utils/toast";
	import bank from "./component/bank/index.vue";
	import supplement from "./component/supplement/index.vue"
	import rate from "./component/rate/index.vue"
	import realName from "@/components/identification/realName/index.vue";
	import operate from "./component/operate/index.vue";
	import {
		useStore
	} from "@/store";
	const store = useStore();
	onLoad((val) => {
		scanResult.value = val.scanResult
	});
	onShow(() => {});
	// 步骤索引
	let stepIndex = ref(1);
	let scanResult = ref(null)
	//法人信息
	let corporateInformation = ref({})
	// 经营信息
	let businessInformation = ref({})
	// 结算信息
	let settlementInformation = ref({})
	// 店铺认证
	let supplementaryInformation = ref({})
	// 结算费率
	let settlementRate = ref({})
	let nextBtn = (val, type) => {
		stepIndex.value += 1;
		console.log("stepIndex.value", stepIndex.value)
		if (type == 1) {
			corporateInformation.value = val
		}
		if (type == 2) {
			businessInformation.value = val
		}
		if (type == 3) {
			settlementInformation.value = val
		}
		if (type == 4) {
			supplementaryInformation.value = val
		}
		if (type == 5) {
			settlementRate.value = val
		}
		if (stepIndex.value === 6) {
			let infomation = {
				corporateInformation: corporateInformation.value,
				businessInformation: businessInformation.value,
				settlementInformation: settlementInformation.value,
				supplementaryInformation: supplementaryInformation.value,
				settlementRate: settlementRate.value
			}

			let channelInfomation = ref(store.channelInfomation)
			let infoStr = JSON.stringify(infomation)
			uni.redirectTo({
				url: `/authentication/lebrush/index?info= ${encodeURIComponent(infoStr)}&type=ENTERPRISE&sn=${scanResult.value}`
			});
			// if (channelInfomation.value == 'SFB6289087') {
			//   uni.redirectTo({
			//     url: `/authentication/lebrush/index?info= ${JSON.stringify(infomation)}&type=ENTERPRISE&sn=${scanResult.value}`,
			//   });
			// }
			// if (channelInfomation.value == 'HLB10086') {
			//   uni.redirectTo({
			//     url: `/authentication/creditCard/index?info= ${JSON.stringify(infomation)}&type=ENTERPRISE&sn=${scanResult.value}`,
			//   });
			// }

		}
	}
	let upBtn = () => {
		stepIndex.value -= 1;
		console.log("stepIndex.value", stepIndex.value)
		if (stepIndex.value === 0) {
			uni.navigateTo({
				url: `/pagesLogin/merchantRegistration/index?selectTypeShow=true`,
			});
		}
	}
</script>
<style lang="scss" scoped>
	@import "./index.scss";
</style>